"""Tests possibility of catching all exceptions inside a class"""
import functools
import logging

def catch_exception(f):
    @functools.wraps(f)
    def func(self, *args, **kwargs):
        try:
            return f(self, *args, **kwargs)
        except Exception as E:
            s = "Error in method %s.%s" % (self.__class__.__name__, f.__name__)
            if hasattr(self, "logger"):
                self.logger.exception(s)
            else:
                logging.exception(s)
            raise
    return func

class Test(object):
    def __init__(self, val):
        self.val = val

    @catch_exception
    def calc(self):
        return self.val / 0

t = Test(3)
t.calc()
